settings.omnibarMaxResults=50;
settings.smartCase=false;
settings.modeAfterYank="Normal"

// https://blog.51cto.com/u_15127658/4541176
api.mapkey('ogg','谷歌搜索',()=>Front.openOmnibar({type:'SearchEngine',extra:'gg'}));
api.mapkey('ogh','github 搜索',()=>Front.openOmnibar({type:'SearchEngine',extra:'gh'}));
api.mapkey('oi','打开 Bilibili 搜索',()=>Front.openOmnibar({type:'SearchEngine',extra:'i'}));
api.mapkey('of','打开 Fsou',()=>Front.openOmnibar({type:'SearchEngine',extra:'f'}));
api.mapkey('oo','打开 SearXNG',()=>Front.openOmnibar({type:'SearchEngine',extra:'f'}));
// 添加搜索-BiliBli

api.addSearchAlias('i','bilibili','https://search.bilibili.com/all?keyword=','s','https://s.search.bilibili.com/main/suggest?func=suggest&suggest_type=accurate&sub_type=tag&main_ver=v1&highlight=&userid=&bangumi_acc_num=1&special_acc_num=1&topic_acc_num=1&upuser_acc_num=3&tag_num=10&special_num=10&bangumi_num=10&upuser_num=3&jsonp=jsonp&term=',function(rt){
    var xst_bilirt=JSON.parse(rt.text);
    if(xst_bilirt.code!='0')return [];
    return xst_bilirt.result.tag.map(ele=>ele.value);
});
// 添加搜索-F
api.addSearchAlias('f','fsoufsou','https://fsoufsou.com/search?q=','s','https://fsoufsou.com/search?q=',function(rt){
    var xst_bilirt=JSON.parse(rt.text);
    if(xst_bilirt.code!='0')return [];
    return xst_bilirt.result.tag.map(ele=>ele.value);
});

// 添加搜索 searx
api.addSearchAlias('o','SearXNG','https://c/search?q=','o','https://searx.be/search?q=',function(rt){
    var xst_bilirt=JSON.parse(rt.text);
    if(xst_bilirt.code!='0')return [];
    return xst_bilirt.result.tag.map(ele=>ele.value);
});

api.addSearchAlias('gh', 'github 搜索', 'https://github.com/search?q=','s',
  'https://api.github.com/search/repositories?q=',
  (res)=>{
    console.log(res)
    res=JSON.parse(res.text)
    res=res.items.map(x=>({html:`
    <div>
      <span style="color:blue;margin-bottom:10px;">★ ${x.stargazers_count}</span>
      <span style="font-size:15px;font-weight:bold;">${x.name}</span>
      <span style="color:#666666">${x.description}</span>
    </div>`
    ,props:{url:x.html_url} }))
    return res;

  }
);

api.addSearchAlias('gg', '谷歌搜索', 'https://www.google.com/search?q=','s',
  'https://www.google.com/complete/search?client=chrome-omni&gs_ri=chrome-ext&oit=1&cp=1&pgcl=7&q=',
  (res)=>JSON.parse(res.text)[1]
);


api.mapkey('<ctrl-y>', 'Show me the money', function() {
    Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
api.mapkey('=i', 'Download all images and yank the image src', function(){
	var res = "";
	document.querySelectorAll('img').forEach(function(el, key, listObj){
		res += "\r\n" + el.src;
		RUNTIME('download', { url: el.src});
	});
	Clipboard.write(res.trim());
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
api.map('gt', 'T');

// an example to remove mapkey `Ctrl-i`
api.unmap('<ctrl-i>');

// set theme
settings.theme = `
.sk_theme {
    font-family: Input Sans Condensed, Charcoal, sans-serif;
    font-size: 10pt;
    background: #24272e;
    color: #abb2bf;
}
.sk_theme tbody {
    color: #fff;
}
.sk_theme input {
    color: #d0d0d0;
}
.sk_theme .url {
    color: #61afef;
}
.sk_theme .annotation {
    color: #56b6c2;
}
.sk_theme .omnibar_highlight {
    color: #528bff;
}
.sk_theme .omnibar_timestamp {
    color: #e5c07b;
}
.sk_theme .omnibar_visitcount {
    color: #98c379;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
    background: #303030;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
    background: #3e4452;
}
#sk_status, #sk_find {
    font-size: 20pt;
}`;
